//
// Created by 66477 on 2022/9/28.
//

#ifndef DATA_STRUCTURE_CTRLUTIL_H
#define DATA_STRUCTURE_CTRLUTIL_H

#include "q1/BiTree5_1.h"
#include "q2/BiTree5_2.h"
#include "q3/BiTree5_3.h"

class CtrlUtil {
public:
    CtrlUtil *start() {
        while (true) {
            cout << "(1-3)Which question to test? :";
            int i;
            cin >> i;
            switch (i) {
                case 1:
                    cout << "(question1)" << endl;
                    q1();
                    break;
                case 2:
                    cout << "(question2)" << endl;
                    q2();
                    break;
                case 3:
                    cout << "(question3)" << endl;
                    q3();
                    break;
                default:
                    return this;
            }
            cout << "-------------" << endl;
        }
    }

    void q1() {
        cout << "Input string create BiTree with DLR:" << endl;
        string s;
        cin >> s;
        BiTree5_1 *biTree51 = new BiTree5_1(s);
        cout << "height:" << biTree51->getHeight() << endl;
        delete biTree51;
    }

    void q2() {
        cout << "Input string create Complete BiTree" << endl;
        string s;
        cin >> s;
        BiTree5_2 *biTree = new BiTree5_2(s);
        cout << "Out Put DLR" << endl;
        biTree->print();
    }

    void q3() {
        cout << "Input string create BiTree with DLR:" << endl;
        string s;
        cin >> s;
        BiTree5_3 *biTree53 = new BiTree5_3(s);
        cout << "DLR:";
        biTree53->printDLR();
        cout << "LDR:";
        biTree53->printLDR();
        cout << "LRD:";
        biTree53->printLRD();
    }
};

#endif //DATA_STRUCTURE_CTRLUTIL_H
